<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript">
	$(function() {
		$('#pid').combotree({
			url : '${pageContext.request.contextPath}/admin/dictionary/dictionaryComboTree',
			parentField : 'pid',
			lines : true,
			panelHeight : 'auto',
			onLoadSuccess : function() {
				parent.$.messager.progress('close');
				$("#pid").combotree('tree').tree("collapseAll");
			}
		});

		$('#form').form({
			url : '${pageContext.request.contextPath}/admin/dictionary/addDictionary',
			onSubmit : function() {
				parent.$.messager.progress({
					title : '提示',
					text : '数据处理中，请稍后....'
				});
				var isValid = $(this).form('validate');
				if (!isValid) {
					parent.$.messager.progress('close');
				}
				return isValid;
			},
			success : function(result) {
				parent.$.messager.progress('close');
				result = $.parseJSON(result);
				if (result.obj == "success") {
					parent.$.messager.alert('成功', result.msg, 'info', function() {
						parent.$.modalDialog.openner_treeGrid.treegrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_treeGrid这个对象，是因为role.jsp页面预定义好了
						parent.$.modalDialog.handler.dialog('close');
					});
				} else if (result.obj == "zdCodeExist") {// 角色名称已经存在
					parent.$.messager.alert('警告', result.msg, 'warning', function() {
						$("#zdCode").attr("value", "");
						$('#zdCode').select();
					});
				} else if (result.obj == "zdNameExist") {// 角色名称已经存在
					parent.$.messager.alert('警告', result.msg, 'warning', function() {
						$("#zdName").attr("value", "");
						$('#zdName').select();
					});
				} else if (result.obj == "") {
					parent.$.messager.alert('错误', result.msg, 'error');
				} else {
					parent.$.messager.alert('警告', result.msg, 'warning');
				}
			}
		});
	});
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
  <div data-options="region:'center',border:false" title="" style="overflow: hidden;">
    <form id="form" method="post">
      <input name="id" type="hidden" value="${dictionary.id}">
      <table class="table table-hover table-condensed">
        <tr>
          <th>字典编号</th>
          <td><input validType="zdCodeValid" id="zdCode" name="dictCode" type="text" placeholder="请输入字典编号"
            class="easyui-validatebox span2" data-options="required:true" value=""></td>
          <th>字典名称</th>
          <td><input validType="zdNameValid" id="zdName" name="dictName" type="text" placeholder="请输入字典名称"
            class="easyui-validatebox span2" data-options="required:true" value=""></td>
        </tr>
        <tr>
          <th>排序</th>
          <td><input name="dictSort" value="100" class="easyui-numberspinner" style="width: 140px; height: 30px;"
            required="required" data-options="editable:false"></td>
          <th>字典分类</th>
          <td><select id="pid" name="pid" style="width: 140px; height: 29px;"></select><img
            src="${pageContext.request.contextPath}/resources/css/images/extjs_icons/cut_red.png"
            onclick="$('#pid').combotree('clear');" /></td>
        </tr>
        <tr>
          <th>备注</th>
          <td colspan="3"><textarea name="dictDesc" rows="2" cols="" class="span5"
              onKeyUp="if(this.value.length>80){this.value=this.value.substring(0,80);}"></textarea></td>
        </tr>
      </table>
    </form>
  </div>
</div>